package main.chapter5.equals;/**
 * @Author xy
 * @Date 2020/6/15 22:57
 * @Description
 */

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMessages_pt_BR;

import java.util.Objects;

/**
 * 文件名称： main.chapter5.equals.Manager.java</br>
 * 初始作者： xy</br>
 * 创建日期： 2020/6/15 22:57</br>
 * 功能说明： TODO <br/>
 * =================================================<br/>
 * 修改记录：<br/>
 * 修改作者        日期       修改内容<br/>
 * ================================================<br/>
 * Copyright (c) 2020-2021 .All rights reserved.<br/>
 */
public class Manager extends Employee {
    private double bonus;

    public Manager(String name, double salary, int year, int month, int day) {
        super(name, salary, year, month, day);
        this.bonus = 0;
    }

    @Override
    public double getSalary(){
        double baseSalary = super.getSalary();
        return baseSalary+bonus;
    }

    public void setBonus(double bonus){
        this.bonus = bonus;
    }

    @Override
    public boolean equals(Object otherObject){
        if(!super.equals(otherObject)){
            return false;
        }
        Manager other = (Manager)otherObject;
        return bonus == other.bonus;
    }

    @Override
    public int hashCode(){
        return Objects.hash(super.hashCode(),bonus);
    }

    @Override
    public String toString(){
        return super.toString()+"[bonus="+bonus+"]";
    }
}
